#ifndef _rxtx_h
#define _rxtx_h

#include <avr/pgmspace.h>

#include "dx6i.h"

#define DSM2_CHANNELS			6
#define DSM2_RX_BAUD			125000
#define DSM2_RX_BUFFER_SIZE		14
#define DSM2_RX_DETECT_CNT		CNT_MSEC / 4

#define TX_BUFFER_SIZE	64
#define TX_SEND			UCSR0B|= (1 << UDRIE0);

#define CH_THR		0
#define CH_ROLL		1
#define CH_PITCH	2
#define CH_YAW		3

#define CH_MIN		200 //146-150 (63)
#define CH_MID		494 //491-498 (511)
#define CH_MAX		800 //836-840 (959)
#define CH_DB		100

void rxtx_init(void);
void rxtx_sync_mode(bool mode);
void dsm2_rx_channels(void);
void tx_push_char(char c);
void tx_push_str(const char *s);
void tx_push_str_P(const char PROGMEM *s);
void tx_push_digit(uint32_t d);
bool ch_is_mid(uint8_t i);
bool ch_is_min(uint8_t i);
bool ch_is_max(uint8_t i);
void dump_channels(void);

#endif
